<?php /* Smarty version 2.6.20, created on 2013-05-25 01:50:46
         compiled from _core/_include/module/_mvc/control/tablerows/handletablerowproduceworker.tpl */ ?>
<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
smarty_core_load_plugins(array('plugins' => array(array('modifier', 'escape', '_core/_include/module/_mvc/control/tablerows/handletablerowproduceworker.tpl', 91, false),)), $this); ?>
function HandleTableRowProduceWorker(gui, item, options) {
  this._gui = gui;
  this._item = item;
  this._options = options;
  this._popupBox = new PopupBox();
  this._popupBox2 = new PopupBox2();
  
  this._user = (options && options.user) ? options.user : null;

  this._date = (options && options.date) ? options.date : null;
  this._parent = (options && options.parent) ? options.parent : null;
  this._callbackFunc = (options && options.callbackFunc) ? options.callbackFunc : function() {};
  
  this._createElements();
};

HandleTableRowProduceWorker.prototype._createElements = function() {
  var gui, _self = this;
  DlmanageUtils.clear(this._gui);
    var span = document.createElement('span');
    span.style.fontWeight = 'bold';
    span.appendChild(document.createTextNode(this._item.pi_quantity + 'X'));
    this._gui.name.appendChild(span);
  
  this._gui.name.appendChild(document.createTextNode(this._item.title));
  if (this._item.pi_model == Constant.MODEL_NAME_USER_PHOTOGRAPHER) {
    if (this._item.pi_selects.length == 1) {
      if (this._item.pi_selects[0].value != '0' && this._item.pi_selects[0].value != '') {
        this._gui.name.appendChild(document.createTextNode(' + ' + this._item.pi_selects[0].value + ' ' + this._item.pi_selects[0].title + 's'));
      }
    }
  }
  if (this._item.cancelled == 0) {
    var note = document.createElement('img');
    note.src = (this._item.v2_notes.length != 0) ? 'images/buttons/note_hilight.png' : 'images/buttons/note.png';
    note.style.cursor = 'pointer';
    note.style.margin = '0 0 0 5px';
    note._produce = this._item;
    note.onclick = function() { var div, pos, func1, func2;
                                var pro = this._produce;
                                div = document.createElement('div');
                                pos = DOMUtils.findPos(this);
                                MiscUtils.dialog(_self._popupBox2, pos, div, null, null, {t: pro.title, width: 760, height: 100});
                                new DialogProduceNote(div, pro, { author: _self._user, now: _self._date, popupBox: _self._popupBox2, callbackFunc: function() { _self._callbackFunc();} });
                                return false;
                              };
    this._gui.name.appendChild(note);
       
  }
  
    a = document.createElement('a');
    a.style.fontSize = '10px';
    a.href = '#';
    
       if(this._item.pdate){
             a.appendChild( document.createTextNode(SimpleDate.format(this._item.pdate) ) );
       }else{ 
             a.appendChild(document.createTextNode('Date'));
       }
    a._produce = this._item;
    
    //console.log( SimpleDate.format(this._item.pdate));
    
      a.onclick = function() { var pos = DOMUtils.findPos(this), date = _self._item.pdate;
                               var div = document.createElement('div');

                               var func1 = function() { 
                                                        
                                                        //if (_self._item.pdate.hours == 0 && _self._item.pdate.minutes == 0 ) {
                                                         // var r = window.confirm('Hours & Minutes is  (00:00), CONTINUE?');
                                                          //if (r) {
                                                          //  _self._popupBox._close();
                                                            

                                                         //  new RequestUtils()._write2([{ n: 'produce', a: [_self._item], r: [] }, { n: 'produceevent', a: [], r: [] }, { n: 'producetrack', a: [], r: []}, { n: 'produceuser', a: [], r: _self._item.pUsers}, { n: '[]', a: [], r: []} ], _self._callbackFunc, { php: Constant.FACTORY + '/customphp/mysqlwrite2.php', pos: pos });
                                                          //}
                                                       // } else {
                                                          _self._popupBox._close();
                                                          
                                                          new RequestUtils()._write2([{ n: 'produce', a: [_self._item], r: [] }, { n: 'produceevent', a: [], r: [] }, { n: 'producetrack', a: [], r: []}, { n: 'produceuser', a: [], r: _self._item.pUsers}, { n: '[]', a: [], r: []} ], _self._callbackFunc, { php: Constant.FACTORY + '/customphp/mysqlwrite2.php', pos: pos });
                                                        //}
                                                      };
                               var func2 = function() { _self._popupBox._close();
                                                        _self._callbackFunc();
                                                      };
                               MiscUtils.dialog(_self._popupBox, pos, div, func1, func2);
                               new DialogAssignee(div, _self._item, { condition: '(d.pEnabled = 1 OR d.vEnabled = 1) and d.isdisplay = 0', date: true, preconUsers: '',nop:true });
                               return false;
                             };  
                             
    if(this._user.type == '<?php echo ((is_array($_tmp=@USER_TYPE_ADMIN)) ? $this->_run_mod_handler('escape', true, $_tmp, 'javascript') : smarty_modifier_escape($_tmp, 'javascript')); ?>
' || this._user.type == '<?php echo ((is_array($_tmp=@USER_TYPE_ACCOUNTANT)) ? $this->_run_mod_handler('escape', true, $_tmp, 'javascript') : smarty_modifier_escape($_tmp, 'javascript')); ?>
') 
    {         
       this._gui.name.appendChild(a); 
    }
  

  this._gui.user.appendChild(document.createTextNode(this._item.user_account));

  if ((this._parent.disposalstatus == 0) && this._item.user_account != '' && this._item.state < 5 && this._item.cancelled == 0) {
    a = document.createElement('a');
    a.style.fontSize = '10px';
    a.href = '#';
    a.appendChild(document.createTextNode('Chg'));
    a.onclick = function() { DlmanageUtils.change(_self._popupBox, DOMUtils.findPos(this), _self._callbackFunc, _self._item, _self._user, _self._date, { func: function(div, produce, condition) { new DialogAssignee(div, produce, { condition: condition, orderTrackId: _self._item.orderTrackId }); } });
                             return false;
                           };
    this._gui.user.appendChild(a);
  }
  
  gui = GuiProduce.instance(this._gui.task, this._gui.dateline, this._gui.progress);
  new HandleProduce(gui, this._item, this._options);
};